﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Crochet.Core.Policy
{
	public abstract class BaseExecutionPolicy : IExecutionPolicy
	{
		protected IScheduler				sRootScheduler;
		protected SchedulerDelegate			sdSchedulerProcess;
		protected ExceptionHandlerDelegate	ehdExceptionHandlerDelegate;

		public BaseExecutionPolicy(IScheduler sRootScheduler, SchedulerDelegate sdSchedulerProcess, ExceptionHandlerDelegate ehdExceptionHandlerDelegate)
		{
			this.sRootScheduler					= sRootScheduler;
			this.sdSchedulerProcess				= sdSchedulerProcess;
			this.ehdExceptionHandlerDelegate	= ehdExceptionHandlerDelegate;
		}

		#region IExecutionPolicy Members

		public IScheduler RootScheduler
		{
			get
			{
				return sRootScheduler;
			}
			set
			{
				sRootScheduler = value;
			}
		}

		public SchedulerDelegate SchedulerProcess
		{
			get
			{
				return sdSchedulerProcess;
			}
		}

		public ExceptionHandlerDelegate ExceptionHandlerDelegate
		{
			get
			{
				return ehdExceptionHandlerDelegate;
			}
		}

		public abstract void Execute(IScheduler sSourceScheduler);

		#endregion

		#region ICloneable Members

		public abstract IExecutionPolicy Clone(SchedulerDelegate sdSchedulerProcess, ExceptionHandlerDelegate ehdExceptionHandlerDelegate);

		#endregion
	}
}
